package factory;
/**
 * 工厂方法模式
 */
public class FactoryMethod {
    public static void main(String[] args) {
        Factory indexFactory = new IndexFactory();
        indexFactory.createCategory();

        Factory blogFactory = new BlogFactory();
        blogFactory.createCategory();

        Factory studyFactory = new StudyFactory();
        studyFactory.createCategory();
    }

    public interface Factory {
        void createCategory();
    }

    public static class IndexFactory implements Factory {
        @Override
        public void createCategory() {
            System.out.println("建立类别：首页");
        }
    }

    public static class BlogFactory implements Factory {
        @Override
        public void createCategory() {
            System.out.println("建立类别：博客");
        }
    }

    public static class StudyFactory implements Factory {
        @Override
        public void createCategory() {
            System.out.println("建立类别：学习");
        }
    }

    public static class DownloadFactory implements Factory {
        @Override
        public void createCategory() {
            System.out.println("建立类别：下载");
        }
    }

    public static class CommunityFactory implements Factory {
        @Override
        public void createCategory() {
            System.out.println("建立类别：社区");
        }
    }
}
